<?php
class User{
	public function loginAction(){
		if(isPost()){
			$name = post("name");
			$pass = post("pass");
			$SQL = sprintf("SELECT * FROM txb_admin_user WHERE Fname='%s' AND Fpwd='%s'",$name,md5($pass));
			$user = $_ENV['db']->get_row($SQL);
			if($user){
				if($user['Fstatus'] == 0){
					$_SESSION['adminuid'] = $user['Fuid'];
					$_SESSION['adminname'] = $user['Fname'];
					$_ENV['db']->updateTable("txb_admin_user",array('' => time()),"Fuid=".$user['Fuid']);
					header("Location: ../index/index");
				}else{
					$_ENV['smarty']->assign("error","你的账号被禁止登陆");
				}
			}else{
				$_ENV['smarty']->assign("error","账号或者密码错误");
			}
		}
	}
	public function logoutAction(){
		session_destroy();
		header("Location: ../user/login");
		die();
	}
}